/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package net.tuandn.training.model.command;

import com.google.gson.JsonArray;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import com.google.gson.JsonParser;
import java.io.FileReader;

/**
 *
 * @author tuandn
 */
public class SlingRequestCaller {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) throws Exception {
        String host = "http://localhost:4502";
        String jsonFile = "D:/query.json";
        String program = "E:/programfiles/curl_7.18.2/curl.exe  -u admin:admin -X DELETE ";

        JsonParser parser = new JsonParser();
        JsonObject list = (JsonObject) parser.parse(new FileReader(jsonFile));
        JsonArray a = list.getAsJsonArray("results");
        for (Object o : a) {
            JsonObject person = (JsonObject) o;

            JsonElement name = person.get("path");
            Runtime.getRuntime().exec(program + host + name);
            System.out.println(name.getAsString());

            Thread.sleep(1000);
        }
    }
}
